/* 基础样式与重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
    background-color: #f5f5f5;
}

/* 网格背景占位 */
.grid-bg-placeholder {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background: linear-gradient(to right, #eee 1px, transparent 1px),
                linear-gradient(to bottom, #eee 1px, transparent 1px);
    background-size: 20px 20px;
}

/* 加载动画 */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out;
}

.hamster-wheel {
    width: 100px;
    height: 100px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #ff6b6b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: relative;
}

.hamster {
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: #ff6b6b;
    border-radius: 50%;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 头部样式 */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    background-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: #333;
    position: relative;
}

.logo::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 3px;
    background-color: #ff6b6b;
    transition: width 0.3s ease;
}

.logo:hover::after {
    width: 100%;
}

.main-nav ul {
    display: flex;
    list-style: none;
}

.main-nav li {
    margin-left: 2rem;
    position: relative;
}

.nav-link {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: color 0.3s ease;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: #ff6b6b;
    transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

.mobile-menu-btn {
    display: none;
    cursor: pointer;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
}

.mobile-menu-btn span {
    display: block;
    height: 3px;
    width: 100%;
    background-color: #333;
    border-radius: 3px;
    transition: all 0.3s ease;
}

/* 英雄区域 */
.hero-section {
    height: 100vh;
    display: flex;
    align-items: center;
    padding: 0 10%;
    position: relative;
    overflow: hidden;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 600px;
}

.typing-text {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #333;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    border-right: 3px solid #ff6b6b;
    animation: typing 3.5s steps(40, end), blink-caret 0.75s step-end infinite;
}

@keyframes typing {
    from { width: 0 }
    to { width: 100% }
}

@keyframes blink-caret {
    from, to { border-color: transparent }
    50% { border-color: #ff6b6b; }
}

.subtitle {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 2rem;
    opacity: 0;
    animation: fadeIn 1s ease 3s forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.scroll-indicator {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 50px;
    border: 2px solid #333;
    border-radius: 15px;
    opacity: 0;
    animation: fadeIn 1s ease 3.5s forwards;
}

.scroll-indicator span {
    display: block;
    width: 6px;
    height: 6px;
    background-color: #333;
    border-radius: 50%;
    margin: 8px auto;
    animation: scrollDown 2s infinite;
}

@keyframes scrollDown {
    0% { opacity: 0; transform: translateY(0); }
    50% { opacity: 1; }
    100% { opacity: 0; transform: translateY(16px); }
}

.hamster-animation {
    position: absolute;
    right: 10%;
    width: 400px;
    height: 400px;
    opacity: 0;
    animation: fadeIn 1s ease 2s forwards;
}

.hamster-coding {
    width: 100%;
    height: 100%;
    background-image: url('hamster-coding.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
    100% { transform: translateY(0px); }
}

/* 项目区域 */
.projects-section {
    padding: 6rem 10%;
    background-color: #fff;
    position: relative;
}

.section-title {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
    display: inline-block;
    left: 50%;
    transform: translateX(-50%);
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(to right, #ff6b6b, #4ecdc4);
}

.project-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.project-card {
    position: relative;
    height: 300px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    padding: 2rem;
    color: #fff;
    z-index: 1;
}

.project-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

.card-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: -2;
    transition: transform 0.5s ease;
}

.project-card:nth-child(1) .card-bg {
    background-image: url('project-bg1.jpg');
}

.project-card:nth-child(2) .card-bg {
    background-image: url('project-bg2.jpg');
}

.project-card:nth-child(3) .card-bg {
    background-image: url('project-bg3.jpg');
}

.project-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}

.project-card:hover .card-bg {
    transform: scale(1.1);
}

.project-card h3 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

.project-card p {
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.project-link {
    display: inline-block;
    padding: 0.8rem 1.5rem;
    background-color: #ff6b6b;
    color: white;
    text-decoration: none;
    border-radius: 30px;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.project-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

.project-link:hover::before {
    left: 100%;
}

.project-link.disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.card-decoration {
    position: absolute;
    width: 100px;
    height: 100px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    top: -30px;
    right: -30px;
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* 关于区域 */
.about-section {
    padding: 6rem 10%;
    background-color: #f9f9f9;
    position: relative;
}

.about-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.about-text {
    flex: 1;
    padding-right: 3rem;
}

.about-text p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.8;
    opacity: 0;
    transform: translateX(-20px);
}

.about-text p:nth-child(1) {
    animation: slideIn 0.8s ease 0.2s forwards;
}

.about-text p:nth-child(2) {
    animation: slideIn 0.8s ease 0.4s forwards;
}

.about-text p:nth-child(3) {
    animation: slideIn 0.8s ease 0.6s forwards;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.skills-animation {
    flex: 1;
    height: 300px;
    position: relative;
}

.code-lines {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: url('code-lines.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0;
    animation: fadeIn 1s ease 1s forwards;
}

/* 页脚 */
.main-footer {
    background-color: #333;
    color: #fff;
    padding: 2rem 10%;
    text-align: center;
    position: relative;
}

.main-footer p {
    margin-bottom: 1rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.social-link {
    color: #fff;
    text-decoration: none;
    transition: color 0.3s ease;
    position: relative;
}

.social-link::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: #ff6b6b;
    transition: width 0.3s ease;
}

.social-link:hover::after {
    width: 100%;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .hero-section {
        padding: 0 5%;
    }
    
    .hamster-animation {
        width: 300px;
        height: 300px;
    }
    
    .about-content {
        flex-direction: column;
    }
    
    .about-text {
        padding-right: 0;
        margin-bottom: 3rem;
    }
}

@media (max-width: 768px) {
    .main-nav {
        position: fixed;
        top: 80px;
        left: -100%;
        width: 100%;
        height: calc(100vh - 80px);
        background-color: rgba(255, 255, 255, 0.95);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        transition: left 0.3s ease;
    }
    
    .main-nav.active {
        left: 0;
    }
    
    .main-nav ul {
        flex-direction: column;
        align-items: center;
    }
    
    .main-nav li {
        margin: 1.5rem 0;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    .mobile-menu-btn.active span:nth-child(1) {
        transform: translateY(9px) rotate(45deg);
    }
    
    .mobile-menu-btn.active span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-btn.active span:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
    }
    
    .hero-section {
        flex-direction: column;
        justify-content: center;
        text-align: center;
    }
    
    .hero-content {
        margin-bottom: 3rem;
    }
    
    .hamster-animation {
        position: relative;
        right: auto;
        margin-top: 2rem;
    }
    
    .project-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }
    
    .typing-text {
        font-size: 2rem;
    }
    
    .hamster-animation {
        width: 200px;
        height: 200px;
    }
}